package com.yalemang.universalindicator;

import android.os.Bundle;

import com.google.android.material.snackbar.Snackbar;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.util.Log;
import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;

import com.yalemang.uindicator.UniversalIndicator;
import com.yalemang.universalindicator.databinding.ActivityMainBinding;
import com.yalemang.universalindicator.fragment.TestFragment;

import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    protected UniversalIndicator indicator;
    private ViewPager2 viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        indicator = findViewById(R.id.indicator);

        indicator.setOrientation(UniversalIndicator.Orientation.HORIZONTAL);
        indicator.setAdapter(new TestAdapter());
        viewPager = findViewById(R.id.view_pager);
        viewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
        viewPager.setAdapter(new FragmentStateAdapter(this) {
            @NonNull
            @Override
            public Fragment createFragment(int position) {
                return new TestFragment();
            }

            @Override
            public int getItemCount() {
                return 100;
            }
        });
        indicator.bindViewPager(viewPager);
        indicator.addOnSelectListener(new UniversalIndicator.OnSelectListener(){
            @Override
            public void onSelectPosition(int oldPosition, int newPosition) {

            }

            @Override
            public void onReSelectPosition(int position) {

            }
        });
    }

}